var alavanca : ativar_alavanca;
var valve : ativar_valve;
var prefab : Transform;
var player : Teste;
var alavanca2 : ativar_alavanca;
var valve2 : ativar_valve;
var alavanca3 : ativar_alavanca;
var valve3 : ativar_valve;
var max_caixas : int;
var max_caixas2 : int;

function Update () 
{
	if(valve.ativar_valve)
	{
		player.enabled = false;
		if(Input.GetKey("a") || Input.GetKey(KeyCode.LeftArrow))
		{
			if(transform.position.x > -5.081883)
			transform.position.x -= 0.01;
		}
		if(Input.GetKey("d") || Input.GetKey(KeyCode.RightArrow))
		{
			if(transform.position.x < 5.056273)
			transform.position.x += 0.01;
		}
	}
	else
	{
		player.enabled = true;
	}
	
	if(valve3.ativar_valve)
	{
		player.enabled = false;
		if(Input.GetKey("a") || Input.GetKey(KeyCode.LeftArrow))
		{
			if(transform.position.x > -5.081883)
			transform.position.x -= 0.01;
		}
		if(Input.GetKey("d") || Input.GetKey(KeyCode.RightArrow))
		{
			if(transform.position.x < 5.056273)
			transform.position.x += 0.01;
		}
	}
	else
	{
		player.enabled = true;
	}
	
	if(alavanca.ativar_alavanca)
	{
		if(max_caixas2 < 1)
		{
			Instantiate(prefab,Vector3(transform.position.x,transform.position.y- 1,transform.position.z),transform.rotation);
			alavanca.ativar_alavanca = false;
		}
	}
	
	if(alavanca3.ativar_alavanca)
	{
		if(max_caixas < 2)
		{
			Instantiate(prefab,Vector3(transform.position.x,transform.position.y- 1,transform.position.z),transform.rotation);
			alavanca3.ativar_alavanca = false;
			max_caixas++;
		}
	}
}
